<template>
  <view class="orderGoods" >
    <!-- <view class="total">共{{ cartInfo.length }}件商品</view> -->
    <view class="row-content">
      <view class="row" v-for="cart,index in cartInfo" :key="cart.id">
		<view class="sortid">
			<view class="sortid-text">{{ index+1 }}</view>
		</view>
		<image :src="cart.productInfo.image" class="pic" />
		
		<view class="text">
			
			<view style="font-weight: bold;">{{ cart.productInfo.storeName }}</view>
			
			<view>价格：{{ cart.truePrice }}</view>
			<view class="cartNume">
				数量：

			<view style="margin-left: 15rpx;" class="input-price">
				{{cart.cartNum}}
			</view>
			
		
			</view>
		</view>
		
		
		<!-- <text class="item-title">{{index+1}}</text>
		<view class="pictrue">
          <image :src="cart.productInfo.sliderImageArr[0]" class="image" />
        </view>
        <view class="text">
			<view>{{ cart.productInfo.storeName }}</view>
			<view>价格：{{ cart.truePrice }}</view>
			<view class="cartNume">
				数量:
				
				<uni-icons v-if="cartEdit==0" style="margin-left: 5rpx;" color="#4E8CEE" type="minus" size="20" @click="del(cart.id,cart.cartNum)"></uni-icons>
				<view style="margin-left: 5rpx;" class="input-price">
					{{cart.cartNum}}
				</view>
				 <uni-icons v-if="cartEdit==0" style="margin-left: 5rpx;" color="#4E8CEE" type="plus-filled" size="20" @click="add(cart.productInfo.id)"></uni-icons>
				
			</view>
        </view> -->
      </view>
    </view>
  </view>
</template>
<script>
	import { getCategory,postCartAdd, getProducts, postCartDel, changeCartNum, getCartCount} from '@/api/store';
export default {
  name: "OrderGoods",
  props: {
	  cartEdit: Number,
    evaluate: Number,
    cartInfo: {
      type: Array,
      default: () => []
    }
  },
  data: function() {
    return {};
  },
  mounted: function() {},
  methods: {
    routerGo(cart) {
      this.$yrouter.push({
        path: "/pages/shop/GoodsEvaluate/index",
        query: { id: cart.unique }
      });
    },
	del(id,num){
		let that = this
			
	
		changeCartNum(id,num - 1).then(function(res){
			if (!res.data) {
					uni.showToast({
						title: res.msg || res.data.msg || res.data.message,
						icon: 'none',
						duration: 2000
					});
					return;
				}
						
			 else {
				uni.showToast({
					title: '减少数量成功',
					icon: 'success',
					duration: 2000,
					complete: () => {
						that.$emit("computePrice")
					}
				});
			}
		})
	},
	// 加入购物车；
	add: function(id) {
		let that = this
	
		let q = {
			productId: id,
			cartNum:1
		};
	
		postCartAdd(q)
			.then(function(res) {
			
				
					if (!res.data) {
						uni.showToast({
							title: res.msg || res.data.msg || res.data.message,
							icon: 'none',
							duration: 2000
						});
						return;
					}
			
				 else {
					uni.showToast({
						title: '添加购物车成功',
						icon: 'success',
						duration: 2000,
						complete: () => {
							that.$emit("computePrice")
						}
					});
				}
			})
			.catch(error => {
			
			});
	},
  }
};
</script>
<style  lang="scss">
	
	.sortid {
		display: flex;
		justify-content: center;
		margin-right: 20rpx;
		
		
	}
	.sortid-text {
		background-color: #3366FF;
		color: #fff;
		width: 40rpx;
		height: 40rpx;
		border-radius: 20rpx;
		display: flex;
		place-content: center;
	}
	.text {
		position: relative;
		    height: 240rpx;
		    display: flex;
		    flex-direction: column;
		    justify-content: space-evenly;
		
		
	}
	.cartNume {
		margin-top: 0.17 * 100rpx;
		display: flex;
		line-height: 34rpx;
	}
	.row {
		display: flex;
		align-items: center;
		padding-left: 12px;
		margin-bottom: 10rpx;
		box-sizing: border-box;
		}
		.row-content{
			width: 100%;
			flex-shrink: 1;
		}
		.pic{
			width: 240rpx;
			height: 240rpx;
			margin-right: 20rpx;
			
		}
</style>